package com.zyz.C_数组.算法;

/**
 * @author: vick
 * @Date: 2025/3/13
 * @Description:
 * @version: 1.0
 */
public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {3, 2, 5, 4, 3, 6};

        //排序的轮次
        for (int i = 1; i < arr.length; i++) {
            //相邻元素的比较
            for (int j = 0; j < arr.length - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        for (int num : arr) {
            System.out.println(num);
        }
    }
}
